import java.security.SecureRandom;

public class Producer extends Thread {
    protected IntBuffer buffer;

    public Producer(IntBuffer buffer) {
        this.buffer = buffer;
    }

    public void run() {
        SecureRandom rand = new SecureRandom();

        while (true) {
            int value = rand.nextInt();
            System.out.println("Producer: " + value);
            try {
                buffer.add(value);
            } catch (Exception e) {
                System.out.println(e);
            }
        }
    }
}
